/*     */ package com.umeng.newxp.view;
/*     */ 
/*     */ import android.app.Dialog;
/*     */ import android.content.Context;
/*     */ import android.content.res.Configuration;
/*     */ import android.content.res.Resources;
/*     */ import android.text.TextUtils;
/*     */ import android.util.DisplayMetrics;
/*     */ import android.view.Display;
/*     */ import android.view.LayoutInflater;
/*     */ import android.view.View;
/*     */ import android.view.ViewGroup;
/*     */ import android.view.ViewGroup.LayoutParams;
/*     */ import android.view.Window;
/*     */ import android.view.WindowManager;
/*     */ import android.view.WindowManager.LayoutParams;
/*     */ import android.webkit.WebView;
/*     */ import android.widget.RelativeLayout;
/*     */ import android.widget.Toast;
/*     */ import com.umeng.common.Log;
/*     */ import com.umeng.common.b;
/*     */ import com.umeng.common.c;
/*     */ import com.umeng.common.util.j;
/*     */ import com.umeng.newxp.Promoter;
/*     */ import com.umeng.newxp.a.e;
/*     */ import com.umeng.newxp.common.ExchangeConstants;
/*     */ import com.umeng.newxp.common.g;
/*     */ import com.umeng.newxp.controller.ExchangeDataService;
/*     */ import com.umeng.newxp.controller.XpListenersCenter.FloatDialogListener;
/*     */ import java.util.List;
/*     */ 
/*     */ public class W extends Dialog
/*     */ {
/*  38 */   private static final String b = W.class.getName();
/*     */ 
/*  40 */   private static W c = null;
/*     */   private Context d;
/*     */   private FloatDialogConfig e;
/*     */   public float a;
/*     */   private ViewGroup f;
/*     */   private c g;
/*     */   private S h;
/*     */   private View i;
/*  55 */   private boolean j = false;
/*     */ 
/*     */   private W(Context paramContext, ExchangeDataService paramExchangeDataService, int paramInt, FloatDialogConfig paramFloatDialogConfig, String paramString, List<Promoter> paramList)
/*     */   {
/*  63 */     super(paramContext, paramInt);
/*  64 */     this.d = paramContext;
/*  65 */     this.e = (paramFloatDialogConfig != null ? paramFloatDialogConfig : new FloatDialogConfig());
/*  66 */     Log.c(b, "FloatDialogConfig is " + paramFloatDialogConfig.toString());
/*  67 */     this.g = c.a(this.d);
/*  68 */     WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes();
/*  69 */     localLayoutParams.height = -1;
/*  70 */     localLayoutParams.width = -1;
/*  71 */     localLayoutParams.gravity = 17;
/*  72 */     localLayoutParams.windowAnimations = this.g.f("umeng_xp_dialog_animations");
/*  73 */     getWindow().setAttributes(localLayoutParams);
/*     */ 
/*  75 */     a(paramContext);
/*     */ 
/*  77 */     this.h = new S(this.e, this.d, this);
/*     */     Object localObject;
/*  78 */     if (!TextUtils.isEmpty(paramString)) {
/*  79 */       localObject = this.h.a();
/*  80 */       String str = paramString + System.currentTimeMillis();
/*  81 */       ((WebView)localObject).loadUrl(str);
/*  82 */       this.i = ((View)localObject);
/*     */     } else {
/*  84 */       localObject = this.h.c(paramList, paramExchangeDataService);
/*  85 */       this.i = ((View)localObject);
/*     */     }
/*  87 */     this.f.addView(this.i, -1, -1);
/*     */   }
/*     */ 
/*     */   protected void a()
/*     */   {
/*  95 */     if ((this.i instanceof P)) {
/*  96 */       boolean bool = ((P)this.i).a();
/*  97 */       if (!bool) {
/*  98 */         this.j = true;
/*  99 */         Log.b(b, "build FImageView failed.please check  promoter is correct.");
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   public static synchronized void a(Context paramContext, ExchangeDataService paramExchangeDataService, FloatDialogConfig paramFloatDialogConfig, List<Promoter> paramList)
/*     */   {
/* 110 */     String str = null;
/* 111 */     if (paramFloatDialogConfig.getNativeFlag() == 0) {
/* 112 */       str = g.b(paramContext, paramExchangeDataService) + "&_random=";
/*     */     }
/*     */ 
/* 115 */     if ((b.a(paramContext, "android.permission.ACCESS_NETWORK_STATE")) && 
/* 116 */       (!b.n(paramContext))) {
/* 117 */       Toast.makeText(paramContext, 
/* 118 */         paramContext.getResources()
/* 119 */         .getString(e.i(paramContext)), 
/* 120 */         1).show();
/* 121 */       return;
/*     */     }
/*     */ 
/* 124 */     if ((c != null) && (c.isShowing()))
/*     */     {
/*     */       try
/*     */       {
/* 131 */         c.dismiss();
/*     */       }
/*     */       catch (Exception localException) {
/* 134 */         Log.c(ExchangeConstants.LOG_TAG, "Reset list dialog...", localException);
/*     */       }
/*     */     }
/*     */ 
/* 138 */     float f1 = Float.parseFloat(paramExchangeDataService.opensize);
/*     */     int k;
/* 140 */     if (f1 >= 1.0F)
/* 141 */       k = ExchangeConstants.full_screen ? 16973841 : 
/* 142 */         16973840;
/*     */     else {
/* 144 */       k = c.a(paramContext).f("umeng_xp_dialog_download_window");
/*     */     }
/*     */ 
/* 147 */     c = new W(paramContext, paramExchangeDataService, k, paramFloatDialogConfig, str, paramList);
/* 148 */     c.a();
/* 149 */     c.a = f1;
/*     */ 
/* 151 */     int[] arrayOfInt = a(paramContext, f1);
/*     */ 
/* 154 */     if ((paramFloatDialogConfig == null) || (!paramFloatDialogConfig.isDelay())) {
/* 155 */       c.show();
/* 156 */       Log.c(b, "show dialog on create...");
/*     */     }
/*     */ 
/* 159 */     c.getWindow().setLayout(arrayOfInt[0], arrayOfInt[1]);
/*     */   }
/*     */ 
/*     */   public static synchronized void a(int paramInt) {
/* 163 */     if ((c != null) && (c.isShowing())) {
/* 164 */       int[] arrayOfInt = a(c.getContext(), c.a);
/* 165 */       c.a(arrayOfInt[0], arrayOfInt[1], paramInt);
/*     */     }
/*     */   }
/*     */ 
/*     */   private static int[] a(Context paramContext, float paramFloat) {
/* 170 */     DisplayMetrics localDisplayMetrics = new DisplayMetrics();
/* 171 */     WindowManager localWindowManager = (WindowManager)paramContext.getSystemService("window");
/* 172 */     localWindowManager.getDefaultDisplay().getMetrics(localDisplayMetrics);
/* 173 */     new j(paramContext);
/*     */ 
/* 175 */     int k = localDisplayMetrics.heightPixels;
/* 176 */     int m = localDisplayMetrics.widthPixels;
/* 177 */     int n = -1;
/* 178 */     int i1 = -1;
/*     */ 
/* 180 */     int i2 = paramContext.getResources().getConfiguration().orientation;
/* 181 */     if ((1.0F > paramFloat) && (0.8F <= paramFloat))
/*     */     {
/* 183 */       if (i2 == 1) {
/* 184 */         n = (int)(0.8F * k);
/* 185 */         i1 = m - j.a(7.0F) * 2;
/*     */       } else {
/* 187 */         n = k - j.a(10.0F) * 2;
/* 188 */         i1 = (int)(0.8F * m);
/*     */       }
/* 190 */     } else if ((0.8F > paramFloat) && (0.6F <= paramFloat))
/*     */     {
/* 192 */       if (i2 == 1) {
/* 193 */         n = (int)(0.6F * k);
/* 194 */         i1 = m - j.a(7.0F) * 2;
/*     */       } else {
/* 196 */         n = k - j.a(10.0F) * 2;
/* 197 */         i1 = (int)(0.6F * m);
/*     */       }
/*     */     }
/*     */ 
/* 201 */     return new int[] { i1, n };
/*     */   }
/*     */ 
/*     */   private void a(Context paramContext) {
/* 205 */     RelativeLayout localRelativeLayout = new RelativeLayout(this.d);
/* 206 */     localRelativeLayout.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
/*     */ 
/* 208 */     LayoutInflater localLayoutInflater = (LayoutInflater)paramContext.getSystemService("layout_inflater");
/* 209 */     View localView = localLayoutInflater.inflate(this.g.e("umeng_xp_floatdialog_content"), null);
/*     */ 
/* 211 */     ViewGroup.LayoutParams localLayoutParams = new ViewGroup.LayoutParams(-1, 
/* 212 */       -1);
/* 213 */     localView.setLayoutParams(localLayoutParams);
/* 214 */     localRelativeLayout.addView(localView, localLayoutParams);
/*     */ 
/* 216 */     this.f = ((ViewGroup)localView.findViewById(this.g.c("umeng_xp_float_dialog_content")));
/*     */ 
/* 218 */     localView.findViewById(this.g.c("umeng_xp_float_dialog_close"))
/* 219 */       .setOnClickListener(new X(this));
/*     */ 
/* 227 */     localView.invalidate();
/* 228 */     setContentView(localRelativeLayout);
/*     */   }
/*     */ 
/*     */   public void show()
/*     */   {
/* 233 */     boolean bool = this.e.isTimeout();
/* 234 */     if (this.e.getListener() != null) {
/* 235 */       this.e.getListener().onShow(bool);
/*     */     }
/* 237 */     if (this.j) {
/* 238 */       Log.b(b, "can`t show float window.[FLAG interrupt = " + this.j + "]  please check log. ");
/* 239 */       return;
/*     */     }
/*     */ 
/* 242 */     if (!bool) {
/* 243 */       super.show();
/*     */ 
/* 245 */       if (!(this.i instanceof WebView))
/*     */         try {
/* 247 */           av localav = (av)this.i;
/* 248 */           localav.b();
/*     */         }
/*     */         catch (ClassCastException localClassCastException) {
/* 251 */           Log.b(b, "FloatDialog template is not LazyImpressionView or WebView");
/*     */         } catch (Exception localException) {
/* 253 */           Log.b(b, "", localException);
/*     */         }
/*     */       else
/* 256 */         Log.a(b, "FloatDialog template is WebView");
/*     */     }
/*     */     else {
/* 259 */       Log.e(b, "FloatDialog timeout unshow.");
/*     */     }
/*     */   }
/*     */ 
/*     */   public void dismiss()
/*     */   {
/* 265 */     super.dismiss();
/* 266 */     if (this.e.getListener() != null)
/* 267 */       this.e.getListener().onClose();
/* 268 */     c = null;
/*     */   }
/*     */ 
/*     */   private synchronized void a(int paramInt1, int paramInt2, int paramInt3)
/*     */   {
/* 278 */     if (c.isShowing()) {
/* 279 */       super.dismiss();
/*     */     }
/* 281 */     getWindow().setLayout(paramInt1, paramInt2);
/* 282 */     b(paramInt3);
/* 283 */     super.show();
/*     */   }
/*     */ 
/*     */   protected void b(int paramInt)
/*     */   {
/* 292 */     if ((this.i != null) && ((this.i instanceof aE))) {
/* 293 */       aE localaE = (aE)this.i;
/* 294 */       localaE.a(paramInt);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\umeng_sdk.jar
 * Qualified Name:     com.umeng.newxp.view.W
 * JD-Core Version:    0.6.2
 */